/* Endless Code Copyright (C) 2009 Jingul,Kim
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 */
package ec.core;

import java.util.HashMap;

import ec.core.event.FocuseEvt;

/**
 * @since 2009
 * @version 1.0
 * @author <a href="mailto:jingul.kim@gmail.com">Jingul,Kim</a>
 */
public class Input {
	private static final HashMap<Integer, Caster> table = new HashMap<Integer, Caster>();
	
	private static Caster focused;
	
	public void add(Caster caster) {
		table.put(caster.hashCode(), caster);
	}
	
	public void remove(Caster caster) {
		table.remove(caster.hashCode());
	}
	
	public Caster getCaster(Integer c) {
		return table.get(c);
	}
	
	public void setFocused(Caster focuse) {
		if(focused != null) {
			focused.processEvent(new FocuseEvt(focused));
		}
		
		focused = focuse;
	}
	
	public Caster getFocused() {
		return focused;
	}
	
	public void lostFocusing() {
		focused = null;
	}
}
